<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="system" tagdir="/WEB-INF/tags/system"%>
<probiz:pageHeading pageHeadingKey="orderRefundList.heading" />

<content tag="buttons">
   <probiz:iconBtn btnType="print" btnTextKey="orderRefundList.button.print" onclick="printRefundList();" />
</content>

<search:searchBox formAction="${ctxPath}/order/orderRefund.html" enableMoreSearch="true">
	<div class="basic_search">
		<search:basicSearch attrPath="op.documentNo" attrNameKey="orderPayment.documentNo" datatype="String"	operator="LIKE" classes="inputtxt" labelWidth="60px"/>
	</div>
	<div class="more_search">
		<table border="0" cellspacing="0" cellpadding="0" class="search_table">
			<search:input attrPath="op.salesOrder.orderNo" attrNameKey="salesOrder.orderNo" datatype="String" operator="LIKE" classes="inputtxt" style="width:150px" labelWidth="60px"/>
			<tr>
				<c:set var="paymentAmountGTE">COL@op.paymentAmount@BigDecimal@GTE</c:set>
				<c:set var="paymentAmountLTE">COL@op.paymentAmount@BigDecimal@LTE</c:set>
				<th width="60px"><label for="${paymentAmountGTE}"><fmt:message key="orderPayment.paymentAmount"/>:</label></th>
				<td>
					<span><input type="text" id="paymentAmountGTE" name="${paymentAmountGTE}" value="${sc==null?requestScope[paymentAmountGTE]:sc.param[paymentAmountGTE]}" style="width:61px"  class="inputtxt" validConf="price" onblur="validateEventHandler();"/></span>
					<fmt:message key ="orderPayment.search.to"/>
					<span><input type="text" id="paymentAmountLTE" name="${paymentAmountLTE}" value="${sc==null?requestScope[paymentAmountLTE]:sc.param[paymentAmountLTE]}" style="width:61px"  class="inputtxt" validConf="price" onblur="validateEventHandler();"/></span>
				</td>
			</tr>
			<search:input attrPath="op.paymentTypeDesc" attrNameKey="orderPayment.paymentTypeDesc2" datatype="String" operator="LIKE" classes="inputtxt" style="width:150px" labelWidth="60px"/>
			<tr>
				<c:set var="createTimeGTE">COL@op.createTime@Date_Begin@GTE</c:set>
				<c:set var="createTimeLTE">COL@op.createTime@Date_End@LTE</c:set>
				<th width="60px"><label for="${createTimeGTE}"><fmt:message key="orderPayment.createTime"/>:</label></th>
				<td>
					<span><input type="text" id="createTimeGTE" name="${createTimeGTE}" value="${sc==null?requestScope[createTimeGTE]:sc.param[createTimeGTE]}" style="width:70px"  class="input_readonly" readonly  onblur="validateEventHandler();"/></span>
					<probiz:ui_datePicker outPut="createTimeGTE" />
					<fmt:message key ="orderPayment.search.to"/>
					<span><input type="text" id="createTimeLTE" name="${createTimeLTE}" value="${sc==null?requestScope[createTimeLTE]:sc.param[createTimeLTE]}" style="width:70px"  class="input_readonly" readonly  onblur="validateEventHandler();"/></span>
					<probiz:ui_datePicker outPut="createTimeLTE" />
				</td>
			</tr>
		</table>
	</div>
</search:searchBox>

<form class="mainForm" name="orderRefundListForm" method="post" action="${ctxPath}/order/orderRefund.html">
	<!--editURLPath is used in TblDecorator-->
	<div class="top clearfix">
		<ul class="tab">
			<li class="curr"><span><fmt:message key="orderRefundList.heading"/></span></li>
		</ul>
		<%@include file="/common/pagingOnlyTop.jsp"%>
	</div>
	<div class="data">		
		<c:set var="checkAll">
			<input type="checkbox" name="allbox" onclick="checkAll(this.form)"	class="checkbox" />
		</c:set>
		<c:set var="isNeedTopPaging" value="true"/>
		
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="list_table" id="orderRefundTable">	
			<tr>
			  	<th width="20"><input onclick="checkAll(this.form)" name="allbox" type="checkbox" value="" /></th>	
				<th style="width:20px;">
					<span class="expand" onclick="toggleScreenAll(this)">&nbsp;</span>
				</th>
				
				<th style="width:10%" class='sortable ${(sc.param["p-sort"] eq 1)?"sorted order1":((sc.param["p-sort"] eq 2)?"sorted order2":"")}'>	
					<a onclick="sortField(this,1,2)"><fmt:message key="orderPayment.documentNo" /></a>
				</th>
				<th style="width:15%" class='sortable ${(sc.param["p-sort"] eq 3)?"sorted order1":((sc.param["p-sort"] eq 4)?"sorted order2":"")}'>	
					<a onclick="sortField(this,3,4)"><fmt:message key="salesOrder.orderNo" /></a>
				</th>
				<th style="width:10%" class='sortable ${(sc.param["p-sort"] eq 5)?"sorted order1":((sc.param["p-sort"] eq 6)?"sorted order2":"")}'>		
					<a onclick="sortField(this,5,6)"><fmt:message key="orderPayment.paymentAmount" /></a>
				</th>
				<th style="width:15%" class='sortable ${(sc.param["p-sort"] eq 7)?"sorted order1":((sc.param["p-sort"] eq 8)?"sorted order2":"")}'>		
					<a onclick="sortField(this,7,8)"><fmt:message key="orderPayment.paymentTypeDesc2" /></a>
				</th>
				<th class='sortable ${(sc.param["p-sort"] eq 9)?"sorted order1":((sc.param["p-sort"] eq 10)?"sorted order2":"")}'>	
					<a onclick="sortField(this,9,10)"><fmt:message key="orderPayment.createTime" /></a>
				</th>
			</tr>
			<c:forEach  items="${orderPaymentList}" var="orderPayment" varStatus="status">
				<tr id="tr${orderPayment.orderPaymentId}" class="${(status.index%2==0)?'even':'odd'}">
					<td>
	    				<input type="checkbox" name="multiIds" value="${orderPayment.orderPaymentId}" title="${orderPayment.documentNo}" class="checkbox" />
					</td>
					<td>
						 <span class="expand toggleScreen" onclick="toggleScreen(this)">&nbsp;</span>                    
					</td>
					<td>
						${orderPayment.documentNo}
					</td>
					<td>
						${orderPayment.salesOrder.orderNo}
					</td>
					<td>
						<common:currencyFormat value="${orderPayment.paymentAmount}"/>
					</td>
					<td>
						${orderPayment.paymentTypeDesc}
					</td>
					<td>
						<common:datetimeFormat date="${orderPayment.createTime}" />
					</td>
				</tr>
				<tr style="display: none;" class="${(status.index%2==0)?'even':'odd'}  sub">
					<td></td>
					<td class="consignee" colspan="10">
						<div class="order_show">
							<table cellspacing="0" cellpadding="0" border="0" width="100%">
								<tr>
									<td style="vertical-align:top;width:30%">
										<table cellspacing="0" cellpadding="0" border="0" width="100%" class="consignee_table">
											<tr>
												<th width="100px;"><fmt:message key="orderPayment.documentNo" />:</th>
												<td>${orderPayment.documentNo}</td>
											</tr>
											<tr>
												<th><fmt:message key="orderPayment.paymentTypeDesc2" />:</th>
												<td>${orderPayment.paymentTypeDesc}</td>
											</tr>
											<c:if test="${not empty orderPayment.usedShopPoint}">
												<tr>
													<th><fmt:message key="orderPayment.usedShopPoint" />:</th>
													<td>${orderPayment.usedShopPoint}</td>
												</tr>
											</c:if>
											<c:if test="${not empty orderPayment.giftCertificateNo}">
												<tr>
													<th><fmt:message key="orderPayment.giftCertificateNo" />:</th>
													<td>${orderPayment.giftCertificateNo}</td>
												</tr>
											</c:if>
											<c:if test="${not empty orderPayment.accountInfo}">
												<tr>
													<th><fmt:message key="orderPayment.accountInfo4Refund" />:</th>
													<td>${orderPayment.accountInfo}</td>
												</tr>
											</c:if>
											<tr>
												<th><fmt:message key="orderPayment.payee" />:</th>
												<td>${orderPayment.payee}</td>
											</tr>
										</table>
									</td>
									<td style="vertical-align:top;width:40%">
										<table cellspacing="0" cellpadding="0" border="0" width="100%" class="consignee_table">
											<tr>
												<th width="100px;"><fmt:message key="salesOrder.orderNo"/>:</th>
												<td>${orderPayment.salesOrder.orderNo}</td>
											</tr>
											<tr>
												<th><fmt:message key="orderPayment.commission"/>:</th>
												<td><common:currencyFormat value="${orderPayment.commission}"/></td>
											</tr>
											<tr>
												<th><fmt:message key="orderPayment.returnReason"/>:</th>
												<td>${orderPayment.returnReason}</td>
											</tr>
										</table>
									</td>
									<td style="vertical-align:top;width:30%">
										<table cellspacing="0" cellpadding="0" border="0" width="100%" class="consignee_table">
											<tr>
												<th width="100px;"><fmt:message key="orderPayment.createTime"/>:</th>
												<td><fmt:formatDate value="${orderPayment.createTime}" pattern="yyyy-MM-dd HH:mm" />&nbsp;</td>
											</tr>
											
											<tr>
												<th><fmt:message key="orderPayment.ipAddress"/>:</th>
												<td>${orderPayment.ipAddress}</td>
											</tr>
											<tr>
												<th><fmt:message key="orderPayment.createBy" />:</th>
												<td><system:operatorUserName userId="${orderPayment.createBy}"/></td>
											</tr>
											<tr>
												<th><fmt:message key="orderPayment.memo" />:</th>
												<td>${orderPayment.memo}</td>
											</tr>
											
										</table>
									</td>
								</tr>
							</table>
						</div>
					</td>
				</tr>	
			</c:forEach>
			<c:if test="${empty orderPaymentList}">
				<tr>
					<td colspan="10" style="text-align:center">
						<fmt:message key="list.empty"/>
					</td>
				</tr>
			</c:if>
		</table>	
		<%@include file="/common/pagingOnly.jsp" %>
	</div>
</form>
<script type="text/javascript">
highlightTableRows("orderRefundTable");

$j(document).ready(function () {
	__FMTExtend = {
		orderRefundList_pleaseSelectOne:"<fmt:message key="orderRefundList.pleaseSelectOne"/>"
	};
	$j.extend(__FMT, __FMTExtend); 
});	

//对已有结果进行排序,ascValue表示升序时对应的值,descValue表示降序时对应的值
function sortField(linkDOM,ascValue,descValue){
	var jThDOM = $j(linkDOM).parent('th');
	if(jThDOM.hasClass("order1")){
		location.replace('${ctxPath}/order/orderRefund.html?p-sort='+descValue);
	}else{
		location.replace('${ctxPath}/order/orderRefund.html?p-sort='+ascValue);
	}
}
	

//显示 隐藏全部
function toggleScreenAll(linkDOM){
	if($j(linkDOM).hasClass("expand")){
		$j(linkDOM).removeClass("expand").addClass("shrink");
		$j('span.toggleScreen').each(function(){
			var jTrThis = $j(this).parents('tr:first');
			var jTrFull = jTrThis.next();
			jTrFull.show();
			$j(this).removeClass("expand").addClass("shrink");
		});
	
	}else{
		$j(linkDOM).removeClass("shrink").addClass("expand");
		$j('span.toggleScreen').each(function(){
			var jTrThis = $j(this).parents('tr:first');
			var jTrFull = jTrThis.next();
			jTrFull.hide();
			$j(this).removeClass("shrink").addClass("expand");
		});
	}
}	

//显示 隐藏详细
function toggleScreen(linkDOM){
	var jTrThis = $j(linkDOM).parents('tr:first');
	var jTrFull = jTrThis.next();
	if(jTrFull.is(":hidden")){
		jTrFull.show();
		$j(linkDOM).removeClass("expand").addClass("shrink");
	}else{
		jTrFull.hide();
		$j(linkDOM).removeClass("shrink").addClass("expand");
	}
	
}	
//打印退款单
function printRefundList(){
	var paraData=$j(":input[name='multiIds']").serializeArray();
	if(paraData.length>0) {		
		var param = $j.param(paraData);
		var page = __ctxPath+'/order/orderRefund.html?doAction=printRefundList';
		window.open(page + "&" + param);
	}else{
		alert(__FMT.orderRefundList_pleaseSelectOne);	 
	}	
}
</script>